/**----------------------------------------
 * @description 消息处理组件
 * @description 兼容消息处理的同时，附加了引擎组件的生命周期管理(需要被 add 到 Node 上)
 * @author      lxc
 * @file        MsgComponent.ts
 * @Date        2022-05-05
 * @version     1.0.0
 * ----------------------------------------
 */

import { IMsgProcess, MsgProcess } from "./MsgProcess";
const {ccclass, property} = cc._decorator;

@ccclass
export class MsgComponent extends cc.Component implements IMsgProcess{
    /**
     * 消息代理
     */
    private msgProxy : MsgProcess = null;

    constructor(){
        super()
        this.msgProxy = new MsgProcess() 
    }

    setPrefix(prefix : string){
        this.msgProxy.setPrefix(prefix) 
    }
    /**
     * 打印 Log日志
     * @param args 
     */
    printLog(str: string, ...args: any) {
        this.msgProxy.printLog(str, ...args);
    }
    /**
     * 打印 Error 日志
     * @param args 
     */
    printError(str: string, ...args: any){
        this.msgProxy.printError(str,...args);
    }
    /**
     * 打印 warn 日志
     * @param str 
     * @param args 
     */
    printWarn(str: string, ...args: any){
        this.msgProxy.printWarn(str,...args);
    }
    /**
     * 打印常显日志
     * @param str 
     * @param args 
     */
    awaysPrint(str: string, ...args: any){
        this.msgProxy.awaysPrint(str,...args);
    }
    /**
     * 初始化消息监听
     */
    initListeners(): void {
        this.msgProxy.initListeners();
    }
    /**
     * 移除组件所有消息监听
     */
    removeListeners(): void {
        this.msgProxy.removeListeners()
    }
    /**
     * 添加 UI 类型事件监听
     */
    addUIListener(msgName: string | number, callBack: Function, priority?: number, swallow?: boolean): void {
        this.msgProxy.addUIListener(msgName,callBack,priority,swallow);
    }
}